package com.example.smartmallserver.demos.web.service.impl;

import com.example.smartmallserver.demos.web.mapper.LoginMapper;
import com.example.smartmallserver.demos.web.pojo.User;
import com.example.smartmallserver.demos.web.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    LoginMapper loginMapper;
    @Override
    public User login(String tel) {
        User user = loginMapper.select(tel);
        if(user == null){
            User user1 = new User();
            user1.setTel(tel);
            loginMapper.add(user1);
            user1 = loginMapper.select(user1.getTel());
            return user1;
        }
         return user;
    }

    @Override
    public User getUserInfoById(Object id) {
        return loginMapper.selectById(id);
    }
}
